﻿using AutoMapper;
using QuanLyGiaoVuDAL.DTO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace QuanLyGiaoVuUI.Models.XepLich
{
    public class LopMonHocXepLichViewModel
    {
        public System.Guid LopMonHocId { get; set; }

        public String MaLopMonHoc { get; set; }

        public System.Guid MaMonHoc { get; set; }

        public System.Guid MaGiangVien1 { get; set; }

        public System.Guid? MaGiangVien2 { get; set; }

        public System.Guid MaHocKy { get; set; }

        public int? MaTietDau { get; set; }

        public int? MaTietSau { get; set; }

        public short Thu { get; set; }

        public System.Nullable<System.Guid> MaPhong { get; set; }

        public int? SiSoToiDa { get; set; }

        public int LoaiLop { get; set; }

        public short TyLeDiem { get; set; }

        public System.Nullable<System.Guid> MaLopChinh { get; set; }

        public Guid? LopSinhVienId { get; set; }

        public bool GiangVienXacNhan { get; set; }

        public bool DaPhanHoi { get; set; }

        public String GhiChu { get; set; }

        public bool DongYMoLop { get; set; }

        public int ThuTuTrongTuan { get; set; }

        public MonHocDTO MonHoc { get; set; }

        public GiangVienDTO GiangVien1 { get; set; }

        public GiangVienDTO GiangVien2 { get; set; }

        public HocKyDTO HocKy { get; set; }

        public TietHocDTO TietDau { get; set; }

        public TietHocDTO TietSau { get; set; }

        public LopMonHocDTO LopChinh { get; set; }

        public LopSinhVienDTO LopSinhVien { get; set; }

        public LichThiDTO LichThi { get; set; }

        public String MaLopVaTenMonHoc
        {
            get
            {
                return MaLopMonHoc + " - " + MonHoc.TenMonHoc;
            }
        }

        public int ThuTuXepLich { get; set; }

        public IList<int> DanhSachKhaNang { get; set; }

        public bool DaXet { get; set; }

        public LopMonHocDTO ToLopMonHocDTO()
        {
            Mapper.CreateMap(typeof(LopMonHocXepLichViewModel), typeof(LopMonHocDTO));
            var lopMonHocDTO = new LopMonHocDTO();
            Mapper.Map(this, lopMonHocDTO);
            return lopMonHocDTO;
        }

        public static IEnumerable<LopMonHocDTO> ToLopMonHocDTOList(IEnumerable<LopMonHocXepLichViewModel> lopMonHocViewModelList)
        {
            List<LopMonHocDTO> lopMonHocDTOList = new List<LopMonHocDTO>();
            foreach (LopMonHocXepLichViewModel viewModel in lopMonHocViewModelList)
            {
                lopMonHocDTOList.Add(viewModel.ToLopMonHocDTO());
            }
            return lopMonHocDTOList;
        }

        public static LopMonHocXepLichViewModel FromLopMonHocDTO(LopMonHocDTO lopMonHocDTO)
        {
            Mapper.CreateMap(typeof(DangKyGioDayDTO), typeof(LopMonHocXepLichViewModel));
            var lopMonHocViewModel = new LopMonHocXepLichViewModel();
            Mapper.Map(lopMonHocDTO, lopMonHocViewModel);
            return lopMonHocViewModel;
        }

        public static IEnumerable<LopMonHocXepLichViewModel> FromLopMonHocDTOList(IEnumerable<LopMonHocDTO> lopMonHocDTOList)
        {
            List<LopMonHocXepLichViewModel> dangKyGioDayViewModelList = new List<LopMonHocXepLichViewModel>();
            foreach (LopMonHocDTO lopMonHocDTO in lopMonHocDTOList)
            {
                dangKyGioDayViewModelList.Add(LopMonHocXepLichViewModel.FromLopMonHocDTO(lopMonHocDTO));
            }
            return dangKyGioDayViewModelList.AsEnumerable<LopMonHocXepLichViewModel>();
        }
    }
}